#!/usr/bin/env bash

#export PROJ_PATH=/root/.jenjins/
#export TOMCAT_APP_PATH=/usr/java/apache-tomcat-7.0.91
killTomcat(){

 pid=`ps -ef|grep tomcat|grep java|awk '{print $2}'`
 echo "tomcat Id list    :$pid"
  if ["$pid"=""]
    then
     echo "no camcat pod alive"
     else
         kill -9 $pid
         fi
}
cd $PROJ_PATH/kpispis-web
mvn clean install
killTomcat
rm -rf $TOMCAT_APP_PATH/webapps/kpispis-web
rm -f  $TOMCAT_APP_PATH/webapps/kpispis-web.war

cp $PROJ_PATH/kpispis-web/target/kpispis-web.war $TOMCAT_APP_PATH/webapps/
cd $TOMCAT_APP_PATH/
sh bin/startup.sh